<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <a-col :span="6">
            <a-form-model-item label="工资期间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salaryDate">
              <a-input :disabled="formDisabled || model.isMate=='1' || model.id!=null" v-model="model.salaryDate"
                placeholder="请输入工资期间"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="工号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeNo">
              <a-input :disabled="formDisabled || model.isMate=='1'" v-model="model.employeeNo"
                placeholder="请输入工号"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeName">
              <a-input :disabled="formDisabled || model.isMate=='1'" v-model="model.employeeName"
                placeholder="请输入姓名"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="人员状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeStatus">
              <a-input :disabled=formDisabled v-model="model.employeeStatus" placeholder="请输入人员状态"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="身份证号码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardNo">
              <a-input :disabled=formDisabled v-model="model.idCardNo" placeholder="请输入身份证号码"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="所属公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="company">
              <a-input :disabled=formDisabled v-model="model.company" placeholder="请输入所属公司"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="team">
              <a-input :disabled=formDisabled v-model="model.team" placeholder="请输入所属团队"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="所属团队部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="depart">
              <a-input :disabled=formDisabled v-model="model.depart" placeholder="请输入所属团队部门"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="所属团队岗位名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="post">
              <a-input :disabled=formDisabled v-model="model.post" placeholder="请输入所属团队岗位名称"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="岗位属性" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postCate">
              <a-input :disabled=formDisabled v-model="model.postCate" placeholder="请输入岗位属性"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="职级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postRank">
              <a-input :disabled=formDisabled v-model="model.postRank" placeholder="请输入职级"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="入职时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="joinDate">
              <a-input :disabled=formDisabled v-model="model.joinDate" placeholder="请输入入职时间"></a-input>
            </a-form-model-item>
          </a-col>

          <a-col :span="6">

            <a-form-model-item label="转正时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="probationDate">
              <a-input :disabled=formDisabled v-model="model.probationDate" placeholder="请输入转正时间"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="最后一次岗位变化引起的薪级调整日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lastDate">
              <a-input :disabled=formDisabled v-model="model.lastDate"   placeholder="请输入最后一次岗位变化引起的薪级调整日期"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="6">
            <a-form-model-item label="最后工作日" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lastWorkDate">
              <a-input :disabled=formDisabled v-model="model.lastWorkDate" placeholder="请输入最后工作日"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="薪级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salaryScale">
              <a-input :disabled=formDisabled v-model="model.salaryScale" placeholder="请输入薪级"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="岗位工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postWages">
              <a-input :disabled=formDisabled v-model="model.postWages" placeholder="请输入岗位工资"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="加1项" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="addItem">
              <a-input :disabled=formDisabled v-model="model.addItem" placeholder="请输入加1项"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="基础工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="basicSalary">
              <a-input :disabled=formDisabled v-model="model.basicSalary"   placeholder="请输入基础工资"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="年功工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="seniorityWage">
              <a-input :disabled=formDisabled v-model="model.seniorityWage"   placeholder="请输入年功工资"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="等级工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gradedWages">
              <a-input :disabled=formDisabled v-model="model.gradedWages"   placeholder="请输入等级工资"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="6">
            <a-form-model-item label="预发绩效" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="preReleasePerformance">
              <a-input :disabled=formDisabled v-model="model.preReleasePerformance" placeholder="请输入预发绩效"></a-input>
            </a-form-model-item>
          </a-col>

          <a-col :span="6">
            <a-form-model-item label="预发绩效补发" :labelCol="labelCol" :wrapperCol="wrapperCol"
              prop="preReleasePerformanceReissue">
              <a-input :disabled=formDisabled v-model="model.preReleasePerformanceReissue"
                placeholder="请输入预发绩效补发"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="工龄工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="seniorityWages">
              <a-input :disabled=formDisabled v-model="model.seniorityWages" placeholder="请输入工龄工资"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="执业金" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="practicingFee">
              <a-input :disabled=formDisabled v-model="model.practicingFee" placeholder="请输入执业金"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="报告审核费" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reportReviewFee">
              <a-input :disabled=formDisabled v-model="model.reportReviewFee" placeholder="请输入报告审核费"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="项目绩效" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectPerformance">
              <a-input :disabled=formDisabled v-model="model.projectPerformance"   placeholder="请输入项目绩效"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="6">
            <a-form-model-item label="经营绩效" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="managePerformance">
              <a-input :disabled=formDisabled v-model="model.managePerformance" placeholder="请输入经营绩效"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="生产绩效" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productPerformance">
              <a-input :disabled=formDisabled v-model="model.productPerformance" placeholder="请输入生产绩效"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="效能工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="efficiencySalary">
              <a-input :disabled=formDisabled v-model="model.efficiencySalary" placeholder="请输入效能工资"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="餐补" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mealAllowance">
              <a-input :disabled=formDisabled v-model="model.mealAllowance" placeholder="请输入餐补"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="住房补贴" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="housingSubsidies">
              <a-input :disabled=formDisabled v-model="model.housingSubsidies" placeholder="请输入住房补贴"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="通讯补贴" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="communicationSubsidy">
              <a-input :disabled=formDisabled v-model="model.communicationSubsidy" placeholder="请输入通讯补贴"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="外派补贴" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="expatriateSubsidy">
              <a-input :disabled=formDisabled v-model="model.expatriateSubsidy" placeholder="请输入外派补贴"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="专项支持费" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="specialSupportFee">
              <a-input :disabled=formDisabled v-model="model.specialSupportFee" placeholder="请输入专项支持费"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="公里数提现" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="kilometersWithdrawal">
              <a-input :disabled=formDisabled v-model="model.kilometersWithdrawal" placeholder="请输入公里数提现"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="应收账款奖励" :labelCol="labelCol" :wrapperCol="wrapperCol"
              prop="accountsReceivableRewards">
              <a-input :disabled=formDisabled v-model="model.accountsReceivableRewards"
                placeholder="请输入应收账款奖励"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="宣传奖励" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="promotionRewards">
              <a-input :disabled=formDisabled v-model="model.promotionRewards" placeholder="请输入宣传奖励"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="其他奖励" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="otherRewards">
              <a-input :disabled=formDisabled v-model="model.otherRewards" placeholder="请输入其他奖励"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="前期已结算" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="previouslySettled">
              <a-input :disabled=formDisabled v-model="model.previouslySettled" placeholder="请输入前期已结算"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="加班工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="overtimeWage">
              <a-input :disabled=formDisabled v-model="model.overtimeWage" placeholder="请输入加班工资"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="其他加项" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="otherAdditions">
              <a-input :disabled=formDisabled v-model="model.otherAdditions" placeholder="请输入其他加项"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="试用期天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="probationPeriodDays">
              <a-input :disabled=formDisabled v-model="model.probationPeriodDays"   placeholder="请输入试用期天数"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="6">
            <a-form-model-item label="试用期薪级工资扣款" :labelCol="labelCol" :wrapperCol="wrapperCol"
              prop="salaryLevelDuringProbationaryAmount">
              <a-input :disabled=formDisabled v-model="model.salaryLevelDuringProbationaryAmount"
                placeholder="请输入试用期薪级工资扣款"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="缺勤扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="absenceDeduction">
              <a-input :disabled=formDisabled v-model="model.absenceDeduction" placeholder="请输入缺勤扣款"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="入离职缺勤天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="resignationDays">
              <a-input :disabled=formDisabled v-model="model.resignationDays"   placeholder="请输入入离职缺勤天数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="入离职缺勤扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="resignationAmount">
              <a-input :disabled=formDisabled v-model="model.resignationAmount"   placeholder="请输入入离职缺勤扣款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="事假天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="leaveDays">
              <a-input :disabled=formDisabled v-model="model.leaveDays"   placeholder="请输入事假天数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="事假扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="personalLeaveAmount">
              <a-input :disabled=formDisabled v-model="model.personalLeaveAmount"   placeholder="请输入事假扣款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="病假天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sickLeaveDays">
              <a-input :disabled=formDisabled v-model="model.sickLeaveDays"   placeholder="请输入病假天数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="病假扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sickLeaveAmount">
              <a-input :disabled=formDisabled v-model="model.sickLeaveAmount"   placeholder="请输入病假扣款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="产假天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maternityLeaveDays">
              <a-input :disabled=formDisabled v-model="model.maternityLeaveDays"   placeholder="请输入产假天数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="产假扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maternityLeaveAmount">
              <a-input :disabled=formDisabled v-model="model.maternityLeaveAmount"   placeholder="请输入产假扣款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="迟到早退次数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lateAndEarlyLeaveTime">
              <a-input :disabled=formDisabled v-model="model.lateAndEarlyLeaveTime"   placeholder="请输入迟到早退次数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="迟到早退扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lateAndEarlyLeaveAmount">
              <a-input :disabled=formDisabled v-model="model.lateAndEarlyLeaveAmount"   placeholder="请输入迟到早退扣款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="缺卡次数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="missCardTime">
              <a-input :disabled=formDisabled v-model="model.missCardTime"   placeholder="请输入缺卡次数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="缺卡扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="missCardAmount">
              <a-input :disabled=formDisabled v-model="model.missCardAmount"   placeholder="请输入缺卡扣款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="旷工天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="absenteeismDays">
              <a-input :disabled=formDisabled v-model="model.absenteeismDays"   placeholder="请输入旷工天数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="旷工扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="absenteeismAmount">
              <a-input :disabled=formDisabled v-model="model.absenteeismAmount"   placeholder="请输入旷工扣款"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="6">
            <a-form-model-item label="应收账款扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="receivableDeduction">
              <a-input :disabled=formDisabled v-model="model.receivableDeduction" placeholder="请输入应收账款扣款"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="其他扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="otherAmount">
              <a-input :disabled=formDisabled v-model="model.otherAmount" placeholder="请输入其他扣款"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="应发工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wagepayable">
              <a-input :disabled=formDisabled v-model="model.wagepayable" placeholder="请输入应发工资"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="累计收入" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accumulatedIncome">
              <a-input :disabled=formDisabled v-model="model.accumulatedIncome"   placeholder="请输入累计收入"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="6">
            <a-form-model-item label="个人社保" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nextMonthSocialAmount">
              <a-input :disabled=formDisabled v-model="model.nextMonthSocialAmount" placeholder="请输入个人社保"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="当月公积金" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="providentFundAmount">
              <a-input :disabled=formDisabled v-model="model.providentFundAmount" placeholder="请输入个人公积金"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="五险一金累计扣款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="insuranceDeduction">
              <a-input :disabled=formDisabled v-model="model.insuranceDeduction"   placeholder="请输入五险一金累计扣款"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="累计个税专项附加扣除金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="personalIncomeTax">
              <a-input :disabled=formDisabled v-model="model.personalIncomeTax"   placeholder="请输入累计个税专项附加扣除金额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="应预缴个人所得税" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payableInAdvance">
              <a-input :disabled=formDisabled v-model="model.payableInAdvance"   placeholder="请输入应预缴个人所得税"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="已预缴个人所得税金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="individualIncomeTaxAmount">
              <a-input :disabled=formDisabled v-model="model.individualIncomeTaxAmount"   placeholder="请输入已预缴个人所得税金额"  ></a-input>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="6">
            <a-form-model-item label="本期应预缴个人所得税" :labelCol="labelCol" :wrapperCol="wrapperCol"
              prop="incomeTaxPayableInAdvance">
              <a-input :disabled=formDisabled v-model="model.incomeTaxPayableInAdvance"
                placeholder="请输入本期应预缴个人所得税"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="前期已发放" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="previouslyDistributed">
              <a-input :disabled=formDisabled v-model="model.previouslyDistributed" placeholder="请输入前期已发放"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="实发工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="netSalary">
              <a-input :disabled=formDisabled v-model="model.netSalary" placeholder="请输入实发工资"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="工资条绑定的员工" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeId">
              <select-user-by-dep :disabled="formDisabled || model.isMate=='1'" v-model="model.employeeId"
                :multi="false" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import SelectCustomerInput from '@/views/scy/components/SelectCustomerInput'
  import moment from 'moment'
  import { mapGetters } from 'vuex'

  export default {
    name: 'ErpHrSalaryPayslipRecordForm',
    components: {
      SelectUserByDep,
      SelectTeamInput,
      SelectCompanyInput,
      SelectCustomerInput
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 },
        },
        confirmLoading: false,
        validatorRules: {
          salaryDate: [{ required: true,pattern:/^([0-9]{4})年([0-9]{1,2})月$/, message: '工资期间格式为XXXX年XX月!'},],
          employeeNo: [{ required: true,message: '请填写工号!'},],
          employeeName: [{ required: true, message: '请填写姓名!'},],
          employeeId: [
            { required: true, message: '请选择当前工资条匹配的员工!'},
          ],
        },
        url: {
          add: "/api/erp/hr/salary/erpHrSalaryPayslipRecord/add",
          edit: "/api/erp/hr/salary/erpHrSalaryPayslipRecord/edit",
          queryById: "/api/erp/hr/salary/erpHrSalaryPayslipRecord/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      ...mapGetters(['userInfo']),
      add () {
       
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.$refs.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
                that.$emit('unButtonDisable');
              }
            }).catch((error)=>{
               that.$emit('unButtonDisable');
             }).finally(() => {
               that.confirmLoading = false;
             })
          }else {
           that.$emit('unButtonDisable');
          }

        })
      },
    }
  }
</script>
